﻿function node_name_onclick(node,select_parent){
	if ((select_parent=='false') & (_MODAL_DIALOG_MODE==1)){
		if(node.level==0){return;}
	}
	if (_MODAL_DIALOG_MODE==1){
		return_value = node.id + _LIST_DELIMITOR + node.value + _LIST_DELIMITOR + node.innerText;
		window.returnValue = return_value;
		window.close();
	}
	document.forms(0).hdn_item_id.value=node.id;
	document.forms(0).submit();
}
//**********************************************************************************************************************
function show_all_channel_to_select(p_goto_url,p_fuseaction, p_text_name_obj, p_hdn_obj, p_hdn_owner_id,p_height,p_width,p_position){
	if (!p_height) p_height = "280pt";
	if (!p_width) p_width = "450pt";
	v_url = _DSP_MODAL_DIALOG_URL_PATH;
	v_url = v_url + "?goto_url=" + p_goto_url + "&fuseaction=" + p_fuseaction + "&hdn_position_id=" + p_position + "&modal_dialog_mode=1" 
	v_url = v_url+ "&" + randomizeNumber();
	sRtn = showModalDialog(v_url,"","dialogWidth="+p_width+";dialogHeight="+p_height+";dialogTop=80pt;status=no;scroll=no;");
	if (!sRtn) return;
	arr_value = sRtn.split(_LIST_DELIMITOR);
	p_hdn_obj.value = arr_value[0];
	document.forms(0).hdn_cate.value = arr_value[2]; 
	p_text_name_obj.value = arr_value[2];
	document.forms(0).submit();
}


//**********************************************************************************************************************
function show_modal_dialog_channel_onclick(p_goto_url,p_fuseaction, p_text_name_obj, p_hdn_obj, p_hdn_owner_id,p_height,p_width,p_position){
	if (!p_height) p_height = "280pt";
	if (!p_width) p_width = "450pt";
	v_url = _DSP_MODAL_DIALOG_URL_PATH;
	v_url = v_url + "?goto_url=" + p_goto_url + "&fuseaction=" + p_fuseaction + "&hdn_position_id=" + p_position + "&modal_dialog_mode=1" 
	v_url = v_url+ "&" + randomizeNumber();
	sRtn = showModalDialog(v_url,"","dialogWidth="+p_width+";dialogHeight="+p_height+";dialogTop=80pt;status=no;scroll=no;");
	if (!sRtn) return;
	arr_value = sRtn.split(_LIST_DELIMITOR);
	p_hdn_obj.value = arr_value[0];
	p_text_name_obj.value = arr_value[2];
}
//=======================================================================================================
function goto_page_onclick(p_button,p_fuseaction,p_direction_obj,p_exception_qa_obj,p_top_obj,p_bottom_obj,p_page_value) {
	if (p_button==1) {
		p_direction_obj.value = "TOP";
		p_exception_qa_obj.value = 0;
		document.forms(0).hdn_page.value= p_page_value;
	}
	//alert (p_top_obj.value); 
	if (p_button==2) {
		if (p_top_obj.value > 0) {
			p_direction_obj.value = "PREVIOUS";
			document.forms(0).hdn_page.value= p_page_value;
		}else{
			return;
		}
		p_exception_qa_obj.value = p_top_obj.value;
	}	
	if (p_button==3) {
		if (p_bottom_obj.value > 0) {
			document.forms(0).hdn_page.value= p_page_value;
			p_direction_obj.value = "NEXT";
		}else{
			return ;
		}
		p_exception_qa_obj.value = p_bottom_obj.value;
	}	
	if (p_button==4) {
		document.forms(0).hdn_page.value= p_page_value;
		p_direction_obj.value = "BOTTOM";
		p_exception_qa_obj.value = 0;
	}	
	document.forms(0).fuseaction.value = p_fuseaction;
	document.forms(0).submit();
	return;
} 
//===================================================================================================
function txt_name_keydown(p_hdn_obj,p_txt_obj,p_hidden_cate){
	var keyCode = (document.layers) ? keyStroke.which : event.keyCode;
	// Phim Enter
	if(keyCode == 13){
		p_hdn_obj.value = 0;
		p_hidden_cate.value = p_txt_obj.value;
		document.forms(0).submit();
		return;
	}	
}
//===================================================================================================
function close_none_submit(p_hdn_obj) {
	if (p_hdn_obj.value != ""){
		document.forms(0).submit();
	}
}
//===================================================================================================
function btn_approve_onclick(p_checkbox_obj,p_hidden_status,p_hidden_obj,p_fuseaction) {
	var list = checkbox_value_to_list(p_checkbox_obj,",");
	if (list) {   //Kiem tra xem co cau hoi nao duoc chon hay khong?
		if(list_count_element(list,",")==1)	{  //Kiem tra xem co phai chon 1 cau hoi hay khong?
			if (!p_checkbox_obj.length){
				if (p_hidden_status.value != 0) {
					p_hidden_obj.value = p_checkbox_obj.value;
					document.forms(0).fuseaction.value = p_fuseaction;
					document.forms(0).submit(); 	
				} else {
					alert("Câu hỏi này chưa có câu trả lời");
					return;
				}
			} else {
				for(i=0;i<p_checkbox_obj.length;i++){
					if (p_checkbox_obj[i].checked){
						if (p_hidden_status[i].value != 0) {
							p_hidden_obj.value = p_checkbox_obj[i].value;
							document.forms(0).fuseaction.value = p_fuseaction;
							document.forms(0).submit(); 	
						} else {
							alert("Câu hỏi này chưa có câu trả lời");
							return;
						}
					}
				}
			}
		} else  {
			alert("Bạn chỉ được chọn một câu hỏi để duyệt");
			return;
		}
	} else {
		alert("Chưa có câu hỏi nào được chọn");
		return;		
	}
}
//===================================================================================================
function list_count_element(the_list,the_separator)
{	
	if (the_list=="") return -1;
	arr_value = the_list.split(the_separator);
	if (arr_value.length > 0){
			return arr_value.length;
	}
	return -1;
}	
//===================================================================================================
function rad_accept_onclick(){
	if (document.all.rad_accept[0].checked == true){
		document.forms(0).hdn_qa_status.value = 2;		
	}else {		
		document.forms(0).hdn_qa_status.value = 1;	
	}
}
//===================================================================================================
function onegate_qa_update_onclick(fuseaction){
	//replaceSource();
	getContent();	
	btn_save_onclick(fuseaction);
}
//===================================================================================================
function cbo_change_onclick(p_select_obj,p_hidden_obj) {
	p_hidden_obj.value = p_select_obj.value ;
	document.forms(0).submit();
}
function cbo_onchange(p_select_obj,p_hidden_obj) {
	p_hidden_obj.value = p_select_obj.value ;
}
//===================================================================================================
function sel_onclick(p_select_obj,p_hidden_obj) {
	p_hidden_obj.value = p_select_obj.value ;
}
//===================================================================================================
function delete_condition_search(p_fuseaction){
	document.forms(0).hdn_cate_id.value=0;
	document.forms(0).hdn_cate.value="";
	document.forms(0).hdn_status.value=-1;
	document.forms(0).hdn_filter.value="";
	document.forms(0).fuseaction.value = p_fuseaction;
	document.forms(0).submit();
}
//===================================================================================================
function page_onclick(p_value){
	document.forms(0).hdn_page.value = p_value;
	document.forms(0).fuseaction.value = 'DISPLAY_ALL_QA_BY_CATE';
	document.forms(0).submit();
}
function show_dialog_all_answerer_onclick(p_goto_url,p_fuseaction, p_text_name_obj, p_text_code_obj, p_hdn_obj, p_hdn_unit_id){
	v_url =  p_goto_url + "?hdn_handle_agency_id="+p_hdn_unit_id + "&fuseaction=" + p_fuseaction + "&modal_dialog_mode=1" + "&" + randomizeNumber();
	sRtn = showModalDialog(v_url,"","dialogWidth=420pt;dialogHeight=280pt;dialogTop=80pt;status=no;scroll=no;");
	if (!sRtn) return;
	arr_value = sRtn.split(_LIST_DELIMITOR);
	p_hdn_obj.value = arr_value[0];
	p_text_code_obj.value = arr_value[1];		
	p_text_name_obj.value = arr_value[2];
}